package com.acme.domain.account;

import com.acme.exceptions.NotEnoughFundsException;


public class SavingAccount extends AbstractAccount
{

	public SavingAccount(final int id, final double amount)
	{
		super(id, amount);
	}

	@Override
	public void deposit(final double amount) throws IllegalArgumentException
	{
		if (amount < 0)
		{
			throw new IllegalArgumentException("Amount can not be negative");
		}
		this.balance += amount;
	}

	@Override
	public void withdraw(final double amount) throws NotEnoughFundsException
	{
		if (amount < 0)
		{
			throw new IllegalArgumentException("Amount can not be negative");
		}
		if (this.balance - amount >= 0)
		{
			this.balance -= amount;
		}
		else
		{
			throw new NotEnoughFundsException();
		}
	}

	public AccountType getAccountType()
	{
		return AccountType.SAVING;
	}
}
